package com.timepies.view;

import android.app.Dialog;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.timepies.R;
import com.timepies.activity.DettaglioPieActivity;
import com.timepies.activity.ElencoPieActivity;

public class PieAbortButton {

	public static Button addTo(final ElencoPieActivity activity) {
		return abort(activity.getEditDialog());
	}

	public static Button addTo(final DettaglioPieActivity activity) {
		return abort(activity.getEditDialog());
	}

	private static Button abort(final Dialog dialog) {
		Button button = (Button) dialog.findViewById(R.id.abort_dialog);
		button.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Log.d(this.getClass().getSimpleName(), "click abort");
				dialog.dismiss();
			}
		});
		return button;
	}

}
